home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / u_man / cat3 / Tcl / setresult.z / setresult
Text File  |  1998-10-30  |  12KB  |  199 lines

  1.  
  2.  
  3.  
  4. TTTTccccllll____SSSSeeeettttRRRReeeessssuuuulllltttt((((3333TTTTccccllll))))                                        TTTTccccllll____SSSSeeeettttRRRReeeessssuuuulllltttt((((3333TTTTccccllll))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      Tcl_SetResult, Tcl_AppendResult, Tcl_AppendElement, Tcl_ResetResult -
  10.      manipulate Tcl result string
  11.  
  12. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.      ####iiiinnnncccclllluuuuddddeeee <<<<ttttccccllll....hhhh>>>>
  14.  
  15.      TTTTccccllll____SSSSeeeettttRRRReeeessssuuuulllltttt(_i_n_t_e_r_p, _s_t_r_i_n_g, _f_r_e_e_P_r_o_c)
  16.  
  17.      TTTTccccllll____AAAAppppppppeeeennnnddddRRRReeeessssuuuulllltttt((((_i_n_t_e_r_p, _s_t_r_i_n_g, _s_t_r_i_n_g, ... , ((((cccchhhhaaaarrrr ****)))) NNNNUUUULLLLLLLL)
  18.  
  19.      TTTTccccllll____AAAAppppppppeeeennnnddddEEEElllleeeemmmmeeeennnntttt(_i_n_t_e_r_p, _s_t_r_i_n_g)                                        |
  20.  
  21.      TTTTccccllll____RRRReeeesssseeeettttRRRReeeessssuuuulllltttt(_i_n_t_e_r_p)
  22.  
  23.      TTTTccccllll____FFFFrrrreeeeeeeeRRRReeeessssuuuulllltttt(_i_n_t_e_r_p)
  24.  
  25. AAAARRRRGGGGUUUUMMMMEEEENNNNTTTTSSSS
  26.      Tcl_Interp     *_i_n_t_e_r_p    (out)     Interpreter whose result is to be
  27.                                          modified.
  28.  
  29.      char           *_s_t_r_i_n_g    (in)      String value to become result for
  30.                                          _i_n_t_e_r_p or to be appended to existing
  31.                                          result.
  32.  
  33.      Tcl_FreeProc   *_f_r_e_e_P_r_o_c  (in)      Address of procedure to call to
  34.                                          release storage at _s_t_r_i_n_g, or
  35.                                          TTTTCCCCLLLL____SSSSTTTTAAAATTTTIIIICCCC, TTTTCCCCLLLL____DDDDYYYYNNNNAAAAMMMMIIIICCCC, or
  36.                                          TTTTCCCCLLLL____VVVVOOOOLLLLAAAATTTTIIIILLLLEEEE.
  37.  
  38.  
  39. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  40.      The procedures described here are utilities for setting the result/error
  41.      string in a Tcl interpreter.
  42.  
  43.      TTTTccccllll____SSSSeeeettttRRRReeeessssuuuulllltttt arranges for _s_t_r_i_n_g to be the return string for the current
  44.      Tcl command in _i_n_t_e_r_p, replacing any existing result.  If _f_r_e_e_P_r_o_c is
  45.      TTTTCCCCLLLL____SSSSTTTTAAAATTTTIIIICCCC it means that _s_t_r_i_n_g refers to an area of static storage that
  46.      is guaranteed not to be modified until at least the next call to
  47.      TTTTccccllll____EEEEvvvvaaaallll.  If _f_r_e_e_P_r_o_c is TTTTCCCCLLLL____DDDDYYYYNNNNAAAAMMMMIIIICCCC it means that _s_t_r_i_n_g was allocated
  48.      with a call to mmmmaaaalllllllloooocccc(((()))) and is now the property of the Tcl system.
  49.      TTTTccccllll____SSSSeeeettttRRRReeeessssuuuulllltttt will arrange for the string's storage to be released by
  50.      calling ffffrrrreeeeeeee(((()))) when it is no longer needed.  If _f_r_e_e_P_r_o_c is TTTTCCCCLLLL____VVVVOOOOLLLLAAAATTTTIIIILLLLEEEE
  51.      it means that _s_t_r_i_n_g points to an area of memory that is likely to be
  52.      overwritten when TTTTccccllll____SSSSeeeettttRRRReeeessssuuuulllltttt returns (e.g. it points to something in a
  53.      stack frame).  In this case TTTTccccllll____SSSSeeeettttRRRReeeessssuuuulllltttt will make a copy of the string
  54.      in dynamically allocated storage and arrange for the copy to be the
  55.      return string for the current Tcl command.
  56.  
  57.      If _f_r_e_e_P_r_o_c isn't one of the values TTTTCCCCLLLL____SSSSTTTTAAAATTTTIIIICCCC, TTTTCCCCLLLL____DDDDYYYYNNNNAAAAMMMMIIIICCCC, and
  58.      TTTTCCCCLLLL____VVVVOOOOLLLLAAAATTTTIIIILLLLEEEE, then it is the address of a procedure that Tcl should call
  59.      to free the string.  This allows applications to use non-standard storage
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. TTTTccccllll____SSSSeeeettttRRRReeeessssuuuulllltttt((((3333TTTTccccllll))))                                        TTTTccccllll____SSSSeeeettttRRRReeeessssuuuulllltttt((((3333TTTTccccllll))))
  71.  
  72.  
  73.  
  74.      allocators.  When Tcl no longer needs the storage for the string, it will
  75.      call _f_r_e_e_P_r_o_c.  _F_r_e_e_P_r_o_c should have arguments and result that match the
  76.      type TTTTccccllll____FFFFrrrreeeeeeeePPPPrrrroooocccc:
  77.  
  78.           typedef void Tcl_FreeProc(char *_b_l_o_c_k_P_t_r);
  79.  
  80.      When _f_r_e_e_P_r_o_c is called, its _b_l_o_c_k_P_t_r will be set to the value of _s_t_r_i_n_g
  81.      passed to TTTTccccllll____SSSSeeeettttRRRReeeessssuuuulllltttt.
  82.  
  83.      If _s_t_r_i_n_g is NNNNUUUULLLLLLLL, then _f_r_e_e_P_r_o_c is ignored and TTTTccccllll____SSSSeeeettttRRRReeeessssuuuulllltttt re-
  84.      initializes _i_n_t_e_r_p's result to point to the pre-allocated result area,
  85.      with an empty string in the result area.
  86.  
  87.      If TTTTccccllll____SSSSeeeettttRRRReeeessssuuuulllltttt is called at a time when _i_n_t_e_r_p holds a result,
  88.      TTTTccccllll____SSSSeeeettttRRRReeeessssuuuulllltttt does whatever is necessary to dispose of the old result
  89.      (see the TTTTccccllll____IIIInnnntttteeeerrrrpppp manual entry for details on this).
  90.  
  91.      TTTTccccllll____AAAAppppppppeeeennnnddddRRRReeeessssuuuulllltttt makes it easy to build up Tcl results in pieces.  It
  92.      takes each of its _s_t_r_i_n_g arguments and appends them in order to the
  93.      current result associated with _i_n_t_e_r_p.  If the result is in its
  94.      initialized empty state (e.g. a command procedure was just invoked or
  95.      TTTTccccllll____RRRReeeesssseeeettttRRRReeeessssuuuulllltttt was just called), then TTTTccccllll____AAAAppppppppeeeennnnddddRRRReeeessssuuuulllltttt sets the result
  96.      to the concatenation of its _s_t_r_i_n_g arguments.  TTTTccccllll____AAAAppppppppeeeennnnddddRRRReeeessssuuuulllltttt may be
  97.      called repeatedly as additional pieces of the result are produced.
  98.      TTTTccccllll____AAAAppppppppeeeennnnddddRRRReeeessssuuuulllltttt takes care of all the storage management issues
  99.      associated with managing _i_n_t_e_r_p's result, such as allocating a larger
  100.      result area if necessary.  Any number of _s_t_r_i_n_g arguments may be passed
  101.      in a single call;  the last argument in the list must be a NULL pointer.
  102.  
  103.      TTTTccccllll____AAAAppppppppeeeennnnddddEEEElllleeeemmmmeeeennnntttt is similar to TTTTccccllll____AAAAppppppppeeeennnnddddRRRReeeessssuuuulllltttt in that it allows
  104.      results to be built up in pieces.  However, TTTTccccllll____AAAAppppppppeeeennnnddddEEEElllleeeemmmmeeeennnntttt takes only
  105.      a single _s_t_r_i_n_g argument and it appends that argument to the current
  106.      result as a proper Tcl list element.  TTTTccccllll____AAAAppppppppeeeennnnddddEEEElllleeeemmmmeeeennnntttt adds backslashes
  107.      or braces if necessary to ensure that _i_n_t_e_r_p's result can be parsed as a
  108.      list and that _s_t_r_i_n_g will be extracted as a single element.  Under normal
  109.      conditions, TTTTccccllll____AAAAppppppppeeeennnnddddEEEElllleeeemmmmeeeennnntttt will add a space character to _i_n_t_e_r_p's
  110.      result just before adding the new list element, so that the list elements
  111.      in the result are properly separated.  However if the new list element is|
  112.      the first in a list or sub-list (i.e. _i_n_t_e_r_p's current result is empty,  |
  113.      or consists of the single character ``{'', or ends in the characters ``  |
  114.      {'') then no space is added.
  115.  
  116.      TTTTccccllll____RRRReeeesssseeeettttRRRReeeessssuuuulllltttt clears the result for _i_n_t_e_r_p, freeing the memory
  117.      associated with it if the current result was dynamically allocated.  It
  118.      leaves the result in its normal initialized state with _i_n_t_e_r_p->_r_e_s_u_l_t
  119.      pointing to a static buffer containing TTTTCCCCLLLL____RRRREEEESSSSUUUULLLLTTTT____SSSSIIIIZZZZEEEE characters, of
  120.      which the first character is zero.  TTTTccccllll____RRRReeeesssseeeettttRRRReeeessssuuuulllltttt also clears the error
  121.      state managed by TTTTccccllll____AAAAddddddddEEEErrrrrrrroooorrrrIIIInnnnffffoooo and TTTTccccllll____SSSSeeeettttEEEErrrrrrrroooorrrrCCCCooooddddeeee.
  122.  
  123.      TTTTccccllll____FFFFrrrreeeeeeeeRRRReeeessssuuuulllltttt is a macro that performs part of the work of
  124.      TTTTccccllll____RRRReeeesssseeeettttRRRReeeessssuuuulllltttt.  It frees up the memory associated with _i_n_t_e_r_p's result
  125.      and sets _i_n_t_e_r_p->_f_r_e_e_P_r_o_c to zero, but it doesn't change _i_n_t_e_r_p->_r_e_s_u_l_t
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. TTTTccccllll____SSSSeeeettttRRRReeeessssuuuulllltttt((((3333TTTTccccllll))))                                        TTTTccccllll____SSSSeeeettttRRRReeeessssuuuulllltttt((((3333TTTTccccllll))))
  137.  
  138.  
  139.  
  140.      or clear error state.  TTTTccccllll____FFFFrrrreeeeeeeeRRRReeeessssuuuulllltttt is most commonly used when a
  141.      procedure is about to replace one result value with another.
  142.  
  143.  
  144. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  145.      Tcl_AddErrorInfo, Tcl_SetErrorCode, Tcl_Interp
  146.  
  147.  
  148. KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS
  149.      append, command, element, list, result, return value, interpreter
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.